<template>
	<basic-container>
		<avue-crud
			:option="option"
			:data="data"
			ref="crud"
			v-model="form"
			:table-loading="loading"
			:permission="permissionList"
			:page="page"
			:cell-class-name="addColor"
			@refresh-change="refreshChange"
			@search-change="searchChange"
			@search-reset="searchReset"
			@current-change="currentChange"
			@selection-change="selectionChange"
			@size-change="sizeChange"
			:cell-style="cellStyle"
			@on-load="onLoad"
		>
			<template slot="search">
				<el-col :md="12" :xs="12">
					<el-form-item labelWidth="100" label="支付时间" style="display: flex;margin-top:1px;">
						<el-date-picker
								text="支付时间"
								v-model="orderPayTime"
								type="daterange"
								range-separator="至"
								size="mini"
								start-placeholder="开始日期"
								end-placeholder="结束日期"
								align="right"
								format="yyyy-MM-dd HH:mm:ss"
								value-format="yyyy-MM-dd HH:mm:ss"
						></el-date-picker>
					</el-form-item>
				</el-col>
			</template>
			<template slot-scope="scope" slot="orderNo">
				<el-button type="text" style="color: #F39800;" size="small" @click="showOrderDetail(scope.row.orderFormId, scope.row.userName)">{{ scope.row.orderNo }}</el-button>
			</template>
			<template slot-scope="scope" slot="menu">
				<el-button type="text" size="small" @click="viewDetail(scope.row)">查看</el-button>
			</template>
			 <template slot="searchMenu">
				 <el-button type="primary" @click="outExcel" size="mini">部分导出</el-button>
				<el-button type="primary" @click="exportExcel" size="mini">全部导出</el-button>
			</template>
		</avue-crud>
		<el-drawer title="订单详情" :with-header="false" :visible.sync="dialogDeatilVisible" size="60%">
			<avue-form :option="optionDetail" v-model="form1">
				<template slot="group1Header">
					<h4 class="avue-group__title">订单详情</h4>
				</template>	
				<template slot="group2Header">
					<h4 class="avue-group__title">卖家信息</h4>
				</template>
				<template slot="group3Header">
					<h4 class="avue-group__title">配货单信息</h4>
				</template>
				<template slot="group4Header">
					<h4 class="avue-group__title">优惠信息</h4>
				</template>
				<template slot="group5Header">
					<h4 class="avue-group__title">收货地址</h4>
				</template>
				<template slot="group6Header">
					<h4 class="avue-group__title">门店自提信息</h4>
				</template>
				<template slot="group7Header">
					<h4 class="avue-group__title">操作历史</h4>
				</template>
				<template slot-scope="scope" slot="menuForm">
					<el-button @click="closeDetailDialog">关闭</el-button>
				</template>

				<template slot-scope="scope" slot="coupon">
					<div>
						<p>
							运费：
							<span style="padding: 0 0.3rem;">{{ form1.actualShipmentAmount }}</span>
						</p>
						<p v-if="form1.orderType != 2">
							店铺优惠：
							<span style="padding: 0 0.3rem;">{{ form1.couponAmountStore }}</span>
						</p>
						<p v-if="form1.orderType != 2">
							平台优惠：
							<span style="padding: 0 0.3rem;">{{ form1.couponAmountPlatform }}</span>
						</p>
						<p v-if="form1.fullCutAmount > 0">
							满减优惠：
							<span style="padding: 0 0.3rem;">{{ form1.fullCutAmount }}</span>
						</p>
						<p v-if="form1.fullDiscountAmount > 0">
							满折优惠：
							<span style="padding: 0 0.3rem;">{{ form1.fullDiscountAmount }}</span>
						</p>
						<p v-if="form1.isUseIntegral">
							紫微星：
							<span style="padding: 0 0.3rem;">{{ form1.integralTotalAmount }}</span>
						</p>
						<p v-if="form1.orderType != 2">
							订单总价：
							<span style="padding: 0 0.3rem;">{{ form1.totalPrice }}</span>
						</p>
						<p v-if="form1.orderType != 2">
							总付款：
							<span style="padding: 0 0.3rem;">{{ form1.lastAmount }}</span>
						</p>
						<p v-if="form1.orderType == 2">
							总付积分：
							<span style="padding: 0 0.3rem;">{{ form1.lastAmount }}</span>
						</p>
					</div>
				</template>

				<template slot-scope="scope" slot="goodsDetails">
					<avue-crud :data="form1.goodsDetail" :option="option1">
						<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
							<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
						</template>
						<template slot-scope="{ row }" slot="goodsName">
							<div>
								{{ row.goodsName }}
								<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
							</div>
						</template>
					</avue-crud>
				</template>

				<template slot-scope="scope" slot="invoiceType">
					<div>
						<p v-if="form1.invoiceType == 0">个人</p>
						<p v-if="form1.invoiceType == 1">单位</p>
						<p v-if="form1.invoiceType == 2">不开发票</p>
					</div>
				</template>
				<template slot-scope="scope" slot="invoiceTitle">
					<p>{{ form1.invoiceTitle }}</p>
				</template>
				<template slot-scope="scope" slot="invoiceNum">
					<p>{{ form1.invoiceTaxNum }}</p>
				</template>

				<template slot-scope="scope" slot="history">
					<div style="padding: 0.2rem;">
						<p v-for="item in form1.historyLog" :key="item.id">
							<span style="padding: 0 0.1rem;" v-if="item.stateInfo">{{ item.stateInfo }}：</span>
							<span style="color: #ff9900;padding: 0 0.2rem;">{{ item.userName }}</span>
							<span style="padding: 0 0.1rem;" v-if="item.stateInfo == '订单取消'">
								于
								<span style="padding: 0 0.1rem;">{{ item.addTime }}</span>
								取消订单
								<p style="padding: 0 0.1rem;">取消原因：{{ item.logInfo }}</p>
							</span>
							<span style="padding: 0 0.1rem;" v-else>
								于
								<span style="padding: 0 0.1rem;">{{ item.addTime }}</span>
								{{ item.logInfo }}
							</span>
						</p>
					</div>
				</template>

				<template slot-scope="scope" slot="distributionSn">
					<div>
						<div class="distribution" v-if="form1.orderDistributionList.length == 0">暂无配货单信息</div>
						<div class="distribution" v-for="item in form1.orderDistributionList" :key="item.id">
							<el-form :model="item">
								<el-form-item>
									<span style="padding: 0.1rem 0.5rem">配货单号：{{ item.distributionSn }}</span>
									<span style="padding: 0.1rem 0.5rem">生成时间：{{ item.addTime }}</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 0">配货单状态：未发货</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 1">配货单状态：已发货</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 2">配货单状态：已完成</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 3">配货单状态：已退款</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 4">配货单状态：已收货</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == -1">配货单状态：退款审核</span>
								</el-form-item>
								<el-form-item v-if="item.orderFormGoodsResultList.length > 0">
									<avue-crud ref="crud2" :option="option1" :data="item.orderFormGoodsResultList">
										<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
											<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
										</template>
										<template slot-scope="{ row }" slot="goodsName">
											<div>
												{{ row.goodsName }}
												<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
											</div>
										</template>
									</avue-crud>
								</el-form-item>
								<el-form-item v-else>
									<avue-crud ref="crud2" :option="option1" :data="form1.goodsDetail">
										<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
											<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
										</template>
										<template slot-scope="{ row }" slot="goodsName">
											<div>
												{{ row.goodsName }}
												<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
											</div>
										</template>
									</avue-crud>
								</el-form-item>
								<!--<el-form-item v-if="item.orderFormGoodsResultList.length !=0">-->
								<!--<avue-crud ref="crud2" :option="option1" :data="form1.goodsDetail">-->
								<!--<template slot-scope="{row}" slot="goodsMainPhotoUrl">-->
								<!--<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />-->
								<!--</template>-->
								<!--</avue-crud>-->
								<!--</el-form-item>-->
								<el-form-item v-if="form1.expressType == 1">
									<p>物流公司：{{ item.ecName }}</p>
									<p>物流单号：{{ item.shipCode }}</p>
									<span v-if="item.expressInfoBean != '' && item.expressInfoBean != undefined && item.expressInfoBean != null">
										<el-steps direction="vertical" :active="item.expressInfoBean.data.length">
											<el-step
												v-for="(obj, index) in item.expressInfoBean.data"
												icon="el-icon-success"
												:key="index"
												style="padding: 0.2rem;"
												:description="obj.time + obj.context"
											></el-step>
										</el-steps>
									</span>
								</el-form-item>
							</el-form>
						</div>
					</div>
				</template>
			</avue-form>
		</el-drawer>
		<el-dialog width="60%" :visible.sync="viewDialogFormVisible" title="详情" @close="closeDialog" append-to-body :close-on-click-modal="false">
			<avue-form ref="formview" v-model="objview" :option="optionview">
				<!-- <template slot-scope="scope" slot="acTitle">
					<div class="viewColor" v-if="objview.acTitle">{{objview.acTitle}}</div>
				</template> -->
			</avue-form>
			<div slot="footer" class="dialog-footer"><el-button @click="closeDialog">关闭</el-button></div>
		</el-dialog>
	</basic-container>
</template>

<script>
import userAccountLog from '@/components/userAccountLog/userAccountLog';
import {  getDetail } from '@/api/order/orderForm';
import { getList } from '@/api/account/userAccount/reconciliation';
import { mapGetters } from 'vuex';
import {getToken} from '@/util/store';
var Dict = JSON.parse(localStorage.getItem('mall-dictionary')).content;
var RECONCILIATIONSTATUS=[{
	label:'对账失败',
	value:0,
	},{
	label:'对账成功',
	value:1,
	},
]
export default {
	data() {
		return {
			idList: [],
			form: {},
			form1: {},
			orderPayTime:[],
			viewDialogFormVisible: false,
			dialogDeatilVisible: false,
			query: {},
			loading: true,
			data: [
				{
					uaName: '你好',
					totalAmount: '1002',
					lockAmount: '120',
					serviceAmount: '130',
					adAmount: '80',
					mobile: '15845245235',
					payPassword: '254252',
					payPasswordSalt: '485648',
					orderId: '1276822226919104513'
				}
			],
			page: {
				pageSize: 10,
				currentPage: 1,
				total: 0
			},
			//页面加载展示用的option
			option: {
				size: 'mini',
				addBtn: false,
				editBtn: false,
				delBtn: false,
				viewBtn: false,
				excelBtn:false,
				select:true,
				selection:true,
				align: 'center',
				tip: true,
				border: true,
				rowKey: 'id',
				height: 'auto',
				indexLabel:'序号',
				index: true,
				// calcHeight: 380,
				menuWidth: 100,
				searchMenuSpan: 6,
				column: [
					{
						label: '店铺名称',
						prop: 'storeName',
						searchSpan: 6,
						width:120,
						search: true,
						rules: [
							{
								required: true,
								message: '请输入店铺名称',
								trigger: 'blur'
							}
						]
					},
					{
						label: '支付单号',
						prop: 'payOrderNum',
						search: true,
						searchSpan: 6,
						width:120,
						rules: [
							{
								required: true,
								message: '请输入支付单号',
								trigger: 'blur'
							}
						]
					},
					{
						label: '订单号',
						search: true,
						prop: 'orderNo',
						slot: true,
						searchSpan: 6,
						width:150,
						rules: [
							{
								required: true,
								message: '请输入订单号',
								trigger: 'blur'
							}
						]
					},
					{
						label: '订单支付时间',
						prop: 'payTime',
						searchSpan: 6,
						width:150,
						type: "date",
						format: "yyyy-MM-dd hh:mm:ss",
						valueFormat: "yyyy-MM-dd hh:mm:ss",
						searchLabelWidth: 100,
						rules: [
							{
								required: true,
								message: '请输入订单支付时间',
								trigger: 'blur'
							}
						]
					},
					{
						label: '订单金额',
						prop: 'orderAmount',
					},
					{
						label: '结算金额',
						prop: 'settlementAmount',
					},
					{
						label: '区域',
						prop: 'queryOrganization',
						search: true,
						searchSpan: 6,
						defaultExpandAll: false,
						dicUrl: '/base/organization/listTree',
						type: 'tree',
						hide:true,
						props: {
							label: 'name',
							value: 'name',
							children: 'childrenNodes'
						}
					},
					{
						label: '区域',
						prop: 'area',
					},
					{
						label: '业务单元',
						prop: 'unit',
						// search: true,
						searchSpan: 6,
						rules: [
							{
								required: true,
								message: '请输入业务单元',
								trigger: 'blur'
							}
						]
					},
					{
						label: '项目',
						prop: 'project',
						// search: true,
						searchSpan: 6,
						rules: [
							{
								required: true,
								message: '请输入项目',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商户号',
						prop: 'businessNum',
					},
					{
						label: '来源银行',
						prop: 'sourceBank',
						search: true,
						searchSpan: 6,
						rules: [
							{
								required: true,
								message: '请输入来源银行',
								trigger: 'blur'
							}
						]
					},
					{
						label: '对账状态',
						prop: 'isCompareBillSuccess',
						search: true,
						type:'select',
						dicData:RECONCILIATIONSTATUS,
						searchSpan: 6,
						rules: [
							{
								required: true,
								message: '请输入对账状态',
								trigger: 'blur'
							}
						]
					},
					{
						label: '手续费',
						prop: 'handingFee',
					}
				]
			},
			objview: {},
			optionview: {
				size: 'mini',
				addBtn: false,
				editBtn: false,
				delBtn: false,
				viewBtn: false,
				align: 'center',
				tip: true,
				border: true,
				rowKey: 'id',
				height: 'auto',
				menuWidth: 100,
				submitBtn: false,
				emptyBtn: false,
				column: [
					{
						label: '店铺名称',
						prop: 'storeName',
						disabled:true,
					},
					{
						label: '支付单号',
						prop: 'payOrderNum',
						disabled:true,
					},
					{
						label: '订单号',
						prop: 'orderNo',
						disabled:true,
					},
					{
						label: '订单支付时间',
						prop: 'payTime',
						labelWidth: 120,
						disabled:true,
					},
					{
						label: '订单金额',
						prop: 'orderAmount',
						disabled:true,
					},
					{
						label: '结算金额',
						prop: 'settlementAmount',
						disabled:true,
					},
					{
						label: '区域',
						prop: 'area',
						disabled:true,
					},
					{
						label: '业务单元',
						prop: 'unit',
						disabled:true,
					},
					{
						label: '项目',
						prop: 'project',
						disabled:true,
					},
					{
						label: '商户号',
						prop: 'businessNum',
						disabled:true,
					},
					{
						label: '来源银行',
						prop: 'sourceBank',
						disabled:true,
					},
					{
						label: '对账状态',
						prop: 'isCompareBillSuccess',
						type:'select',
						disabled:true,
						dicData:RECONCILIATIONSTATUS,
						disabled:true,
					},
					{
						label: '手续费',
						prop: 'handingFee',
						disabled:true,
					},
					{
						label: '失败原因',
						prop: 'failureReason',
						type:'textarea',
						disabled:true,
					},
				]
			},
			//查看详情
			optionDetail: {
				size: 'mini',
				submitBtn: false,
				emptyBtn: false,
				labelWidth: '100',
				group: [
					{
						prop: 'group1',
						column: [
							{
								label: '订单编号',
								prop: 'orderId',
								type: 'text',
								disabled: true
							},
							{
								label: '订单状态',
								type: 'select',
								prop: 'orderStatus',
								disabled: true,
								dicData: Dict.orderStatusEnum
							},
							{
								label: '订单总金额',
								prop: 'totalPrice',
								type: 'text',
								disabled: true
							},
							{
								label: '买家名称',
								prop: 'userName',
								disabled: true
							},
							{
								label: '卖家名称',
								prop: 'storeName',
								disabled: true
							},
							{
								label: '支付方式',
								prop: 'payWay',
								type: 'select',
								dicData: Dict.payWayEnum,
								disabled: true
							},
							{
								label: '下单时间',
								prop: 'addTime',
								disabled: true
							}
						]
					},
					{
						//卖家信息
						prop: 'group2',
						column: [
							{
								label: '店铺名称',
								prop: 'storeName',
								disabled: true
							},
							{
								label: '卖家名称',
								prop: 'storeName',
								disabled: true
							},
							{
								label: '电话号码',
								prop: 'sellerPhoneNumber',
								disabled: true
							},
							{
								label: '详细地址',
								prop: 'sellerAddress',
								disabled: true
							}
						]
					},
					{
						//配货单信息
						prop: 'group3',
						column: [
							{
								prop: 'distributionSn',
								formslot: true,
								span: 24
							}
						]
					},
					{
						//优惠信息
						prop: 'group4',
						column: [
							{
								prop: 'coupon',
								formslot: true
							}
						]
					},
					{
						//收货地址
						prop: 'group5',
						column: [
							{
								label: '收货人',
								prop: 'trueName',
								disabled: true
							},
							{
								label: '收货地址',
								prop: 'address',
								disabled: true
							},
							{
								label: '详细地址',
								prop: 'areaInfo',
								disabled: true
							},
							{
								label: '电话号码',
								prop: 'mobile',
								disabled: true
							},
							{
								label: '买家留言',
								prop: 'buyerMsg',
								disabled: true
							},
							{
								label: '发票类型',
								prop: 'invoiceType',
								formslot: true,
								display: true
							},
							{
								label: '发票抬头',
								prop: 'invoiceTitle',
								display: true,
								formslot: true
							},
							{
								label: '纳税人识别号',
								prop: 'invoiceNum',
								labelWidth: 120,
								display: true,
								formslot: true
							}
						]
					},
					{
						//门店自提信息
						prop: 'group6',
						display: false,
						column: [
							{
								label: '配货单号',
								prop: 'distributionSn',
								disabled: true
							},
							{
								label: '自提时间',
								prop: 'storeWillCallTime',
								disabled: true
							},
							{
								label: '门店信息',
								prop: 'storeWillInfo',
								disabled: true
							},
							{
								label: '操作说明',
								prop: 'text3',
								disabled: true
							}
						]
					},
					{
						//操作历史
						prop: 'group7',
						column: [
							{
								prop: 'history',
								formslot: true,
								span: 24
							}
						]
					}
				]
			},
			//宝贝详情
			option1: {
				border: true,
				header: false,
				menu: false,
				size: 'mini',
				align: 'center',
				menuAlign: 'center',
				column: [
					{
						label: '宝贝图片',
						prop: 'goodsMainPhotoUrl',
						width: 150,
						slot: true
					},
					{
						label: '宝贝简介',
						align: 'left',
						slot: true,
						prop: 'goodsName'
					},
					{
						label: '商品类型',
						width: 150,
						prop: 'choiceType',
						dicData: Dict.GOODS_CHOICE_TYPE
					},
					{
						label: '规格',
						prop: 'specInfo'
					},
					{
						label: '单价',
						width: 100,
						prop: 'price'
					},
					{
						label: '数量',
						width: 100,
						prop: 'count'
					}
				]
			},
		};
	},
	components: {
		userAccountLog
	},
	computed: {
		...mapGetters(['permission', 'userInfo']),
		permissionList() {
			return {};
		}
	},
	methods: {
		//导出对账
		exportExcel(){
			console.log(this.query);
			let token = getToken();
			let storeName = this.query.storeName === undefined ? "" : this.query.storeName;
			let payOrderNum = this.query.payOrderNum === undefined ? "" : this.query.payOrderNum;
			let orderNo = this.query.orderNo === undefined ? "" : this.query.orderNo;
			let queryOrganization = this.query.queryOrganization === undefined ? "" : this.query.queryOrganization;
			let sourceBank = this.query.sourceBank === undefined ? "" : this.query.sourceBank;
			let isCompareBillSuccess = this.query.isCompareBillSuccess === undefined ? "" : this.query.isCompareBillSuccess;
			window.location.href =
						'order/compareBill/outExcel?token=' + token +
						'&storeName=' + storeName +
						'&payOrderNum=' + payOrderNum +
						'&orderNo=' + orderNo +
						'&queryOrganization=' + queryOrganization +
						'&sourceBank=' + sourceBank +
						'&isCompareBillSuccess=' + isCompareBillSuccess;

		},
		outExcel(){
			console.log(this.query);
			if (this.idList.length > 0){
			let token = getToken();
			let storeName = this.query.storeName === undefined ? "" : this.query.storeName;
			let payOrderNum = this.query.payOrderNum === undefined ? "" : this.query.payOrderNum;
			let orderNo = this.query.orderNo === undefined ? "" : this.query.orderNo;
			let queryOrganization = this.query.queryOrganization === undefined ? "" : this.query.queryOrganization;
			let sourceBank = this.query.sourceBank === undefined ? "" : this.query.sourceBank;
			let isCompareBillSuccess = this.query.isCompareBillSuccess === undefined ? "" : this.query.isCompareBillSuccess;
			let idList=this.idList;
			window.location.href =
					'order/compareBill/outExcel?token=' + token +
					'&storeName=' + storeName +
					'&payOrderNum=' + payOrderNum +
					'&orderNo=' + orderNo +
					'&queryOrganization=' + queryOrganization +
					'&sourceBank=' + sourceBank +
					'&isCompareBillSuccess=' + isCompareBillSuccess+
					'&idList=' + idList;
				setTimeout(()=>{
					this.idList = [];
					this.onLoad(this.page, this.query);
				},500)
			}else {
				this.$message({
					type: "error",
					message: "至少选择一笔数据"
				});
			}
		},
		viewDetail(row) {
			this.objview = row;
			console.log(this.objview,'11111111111111111111111111');
			if(row.area == "") {
				this.objview.area = '无'
			}
			if (row.unit == "") {
				this.objview.unit = '无'
			}
			if (row.project == "") {
				this.objview.project = '无'
			}
			if (row.failureReason == "") {
				this.objview.failureReason = '无'
			}
			this.viewDialogFormVisible = true;
		},
		closeDialog() {
			this.$nextTick(() => {
				this.$refs['formview'].clearValidate();
				this.$refs['formview'].resetForm();
			});
			this.viewDialogFormVisible = false;
		},
		//关闭订单详情
		closeDetailDialog() {
			this.dialogDeatilVisible = false;
		},
		//查看订单详情
		showOrderDetail(id, userName) {
			getDetail(id).then(res => {
				if (res.data.code == 200) {
					let data = res.data.data;
					this.form1.userName = userName || '';
					this.form1.orderId = data.orderForm.orderId;
					this.form1.addTime = data.orderForm.addTime;
					this.form1.payWay = data.orderForm.payWay;
					this.form1.storeName = data.orderForm.storeName;
					this.form1.orderStatus = data.orderForm.orderStatus;
					this.form1.sellerPhoneNumber = data.orderForm.sellerPhoneNumber;
					this.form1.sellerAddress = data.orderForm.sellerAddress;
					this.form1.orderDistributionList = data.orderDistributionList;
					this.form1.goodsDetail = data.orderGoodsList;
					this.form1.trueName = data.orderAddress.trueName;
					this.form1.zip = data.orderAddress.zip;
					this.form1.address = data.orderAddress.provinceAreaName + data.orderAddress.cityAreaName + data.orderAddress.countyAreaName;
					this.form1.areaInfo = data.orderAddress.areaInfo;
					this.form1.mobile = data.orderAddress.mobile;
					this.form1.buyerMsg = data.orderFormInfoResultList[0].buyerMsg;
					this.form1.invoiceType = data.orderFormInfoResultList[0].invoiceType; //发票类型
					this.form1.invoiceTitle = data.orderFormInfoResultList[0].invoiceTitle; //发票抬头
					this.form1.invoiceTaxNum = data.orderFormInfoResultList[0].invoiceTaxNum; //纳税人识别号
					this.form1.expressType = data.orderFormInfoResultList[0].expressType; //运输类型
					this.form1.expressCompanyName = data.orderFormInfoResultList[0].expressCompanyName; //物流公司名
					this.form1.shipCode = data.orderFormInfoResultList[0].shipCode; //快递单号
					this.form1.totalPrice = data.orderForm.totalPrice; //订单总价
					this.form1.lastAmount = data.orderFormAmount[0].lastAmount; //总付款
					this.form1.actualShipmentAmount = data.orderFormAmount[0].actualShipmentAmount; //运费
					this.form1.couponAmountPlatform = data.orderFormAmount[0].couponAmountPlatform; //平台优惠
					this.form1.fullCutAmount = data.orderFormAmount[0].fullCutAmount; //满减优惠fullDiscountAmount
					this.form1.fullDiscountAmount = data.orderFormAmount[0].fullDiscountAmount; //满折优惠
					this.form1.couponAmountStore = data.orderFormAmount[0].couponAmountStore; //店铺优惠
					this.form1.isUseIntegral = data.orderFormAmount[0].isUseIntegral; //是否使用积分抵扣
					this.form1.integralTotalAmount = data.orderFormAmount[0].integralTotalAmount; //积分抵扣金额
					this.form1.historyLog = data.logList; //操作历史
					this.form1.orderType = data.orderForm.orderType; //订单类型
					console.log(this.form1.historyLog);
					if (data.orderDistributionList.length > 0) {
						this.form1.storeWillCallTime = data.orderDistributionList[0].storeWillCallBeginTime + data.orderDistributionList[0].storeWillCallEndTime;
					}
					if (data.orderForm.orderType == 2) {
						//积分订单
						this.optionDetail.group[0].column[2].label = '订单总积分';
					} else {
						//普通订单
						this.optionDetail.group[0].column[2].label = '订单总金额';
					}
				} else {
					return;
				}
			});
			setTimeout(() => {
				console.log(this.form1.orderType);
				if (this.form1.orderType == 2) {
					//积分订单
					this.optionDetail.group[4].column[5].display = false; //发票类型
					this.optionDetail.group[4].column[6].display = false; //发票抬头
					this.optionDetail.group[4].column[7].display = false; //纳税人识别号
					console.log(this.optionDetail.group);
				} else {
					//普通订单
					this.optionDetail.group[4].column[5].display = true; //发票类型
					this.optionDetail.group[4].column[6].display = true; //发票抬头
					this.optionDetail.group[4].column[7].display = true; //纳税人识别号
				}

				if (this.form1.invoiceType == 0) {
					//个人发票
					this.optionDetail.group[4].column[6].display = true;
					this.optionDetail.group[4].column[7].display = false;
				} else if (this.form1.invoiceType == 2) {
					//不开发票
					this.optionDetail.group[4].column[6].display = false;
					this.optionDetail.group[4].column[7].display = false;
				} else if (this.form1.invoiceType == 1) {
					this.optionDetail.group[4].column[6].display = true;
					this.optionDetail.group[4].column[7].display = true;
				}
			}, 1000);
			this.dialogDeatilVisible = true;
		},
		cellStyle({row,column,rowIndex,columnIndex}){
			if(columnIndex==13){
			  if(row.isCompareBillSuccess== 0){//对账失败
				return {
					backgroundColor: 'red'
				}
			  }else{
				return {
					backgroundColor: '#B3E353'
				}
			  }
			}
		  },
		//以下是页面加载店铺需要用到的方法
		searchReset() {
			this.query = {}; // 清空搜索条件时需要保留tab状态对应的用户type
			this.onLoad(this.page);
		},
		searchChange(params, done) {
			this.page.currentPage = 1;
			params.orderPayTimeStart = this.orderPayTime[0];
			params.orderPayTimeEnd = this.orderPayTime[1];
			this.query = params;
			this.onLoad(this.page, params, done);
		},
		currentChange(currentPage) {
			this.page.currentPage = currentPage;
		},
		sizeChange(pageSize) {
			this.page.pageSize = pageSize;
		},
		refreshChange() {
			this.onLoad(this.page);
		},
		selectionChange(list) {
			let idList = []
			if (list.length > 0) {
				for (let item of list) {
					idList.push(item.id)
				}
				console.log(idList)
				this.idList = idList
			} else {
				this.idList = [];
			}
		},
		onLoad(page, params = {}, done) {
			this.loading = true;
			console.log(params)
			console.log(this.query)
			getList(page.currentPage, page.pageSize, Object.assign(params,this.query)).then(res => {
				if(done){
					done();
				}
			this.loading = false;
				const data = res.data;
				console.log(data);
				this.page.total = data.count;
				this.data = data.data;
			});
		},
		addColor({row,column,rowIndex,columnIndex}){
			if(columnIndex==3){
				return 'cell-color'
			}
		}
	}
};
</script>

<style>
.dialog-footer {
	text-align-last: center;
	
}
	.cell-color .cell button{
		color: #2e8ded!important;
	}
</style>
